from odoo import models, api, fields


class PeDeviceCategory(models.Model):
    _name = 'pe.device.category'
    _description = '设备类型'
    _sql_constraints = [('name_unique', 'UNIQUE(name)', '名称需要唯一')]

    name = fields.Char(string='名称', required=True)
    description = fields.Char(string='描述')


class PeDeviceBrand(models.Model):
    _name = 'pe.device.brand'
    _description = '设备品牌'
    _sql_constraints = [('name_unique', 'UNIQUE(name)', '名称需要唯一')]

    name = fields.Char(string='名称', required=True)
    description = fields.Char(string='描述')


class PeDeviceAccessory(models.Model):
    _name = 'pe.device.accessory'
    _description = '配件'

    name = fields.Char(string='名称')
    pe_device_accessory_category_id = fields.Many2one(string='配件类别', comodel_name='pe.device.accessory.category')
    description = fields.Char(string='描述')


class PeDeviceAccessoryCategory(models.Model):
    _name = 'pe.device.accessory.category'
    _description = '配件类别'

    name = fields.Char(string='名称')
    description = fields.Char(string='描述')


class PeDeviceTag(models.Model):
    _name = 'pe.device.tag'
    _description = '设备标签'

    name = fields.Char(string='标签名称')
    color = fields.Integer(string='标签颜色', default=8)


class PeDevicePropertyCategory(models.Model):
    _name = 'pe.device.property.category'
    _description = '属性类别'

    name = fields.Char(string='名称')
